package cn.meeh.sscircle.common.widget;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import cn.meeh.sscircle.R;

/**
 * Created by Zachary on 15/7/27.
 */
@SuppressLint("NewApi")
public class ActionBar extends LinearLayout {
    public static enum COLORMODE {
        BLACK
    }

    private Context mContext;
    private Button actionLeftIV;
    private Button actionRightIV;
    private TextView titleTV;
    private RelativeLayout customHeader;
    private TextView tvBtn;

    public RelativeLayout getCustomHeader() {
        return customHeader;
    }

    public void setCustomHeader(RelativeLayout customHeader) {
        this.customHeader = customHeader;
    }


    public Button getActionLeftIV() {
        return actionLeftIV;
    }

    public Button getActionRightIV() {
        return actionRightIV;
    }

    public TextView getTitleTV() {
        return titleTV;
    }

    public TextView getTvBtn() {
        return tvBtn;
    }

    public ActionBar(Context context) {
        super(context);
        ((Activity) context).getLayoutInflater().inflate(R.layout.header, this);
        mContext = context;
        initialize();
    }

    public ActionBar(Context context, AttributeSet attrs) {
        super(context, attrs);
        ((Activity) context).getLayoutInflater().inflate(R.layout.header, this);
        mContext = context;
        initialize();
    }

    @SuppressWarnings("NewApi")
    public ActionBar(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        ((Activity) context).getLayoutInflater().inflate(R.layout.header, this);
        mContext = context;
        initialize();
    }

    public void setColorMode(COLORMODE mode) {
        switch (mode) {
            case BLACK:
                setBlackMode();
                break;
        }
    }

    private void setBlackMode() {
        actionLeftIV.setTextColor(Color.WHITE);
        actionLeftIV.setBackgroundDrawable(null);
        actionRightIV.setTextColor(Color.WHITE);
        actionRightIV.setBackgroundDrawable(null);
        titleTV.setTextColor(Color.WHITE);
        customHeader.setBackgroundColor(Color.parseColor("#27283c"));
    }



    private void initialize() {
        actionLeftIV = (Button) findViewById(R.id.actionLeftIV);
        actionRightIV = (Button) findViewById(R.id.actionRightIV);
        titleTV = (TextView) findViewById(R.id.titleTV);
        customHeader = (RelativeLayout) findViewById(R.id.customHeader);
        tvBtn=(TextView)findViewById(R.id.actionBtn);
        setColorMode(COLORMODE.BLACK);
    }
}
